﻿Module Module1

	Public Structure TimeTaken
		Public Year As Integer
		Public Month As Integer
		Public Day As Integer
	End Structure

	Public Structure Reading
		Public Taken As TimeTaken
		Public Humidity As Single
		Public Temperature As Single
	End Structure

	Declare Function GetTotal Lib "C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Log\Debug\Log.dll" () As Integer
	Declare Function GetAge Lib "C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Log\Debug\Log.dll" () As Integer
	Declare Function OpenLogTagFile Lib "C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Log\Debug\Log.dll" (ByVal filePath As String) As Long
	Declare Function StringTest Lib "C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Log\Debug\Log.dll" (ByVal value As Byte(), ByRef number As Integer) As Long

	' LogTag function
	Declare Function OpenTagFile Lib "C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Log\Debug\Log.dll" (ByVal fileName As String) As Integer
	Declare Function GetReadingsCount Lib "C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Log\Debug\Log.dll" (ByVal handle As Integer) As Integer
	Declare Function GetReading Lib "C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Log\Debug\Log.dll" (ByVal handle As Integer, ByVal Index As Integer, ByRef reading As Reading) As Boolean

	Sub Main()
		Dim encoder As New System.Text.ASCIIEncoding()
		Dim handle As Integer
		Dim index As Long
		Dim count As Long


		index = 1
		handle = OpenTagFile("c:\test.ltd")
		count = GetReadingsCount(handle)

		Dim reading As Reading = New Reading()

		GetReading(handle, 0, reading)
		MsgBox(count)
		MsgBox(reading.Taken.Year & "/" & reading.Taken.Month & "/" & reading.Taken.Day & " : " & reading.Humidity & ", " & reading.Temperature)

		'MsgBox(GetTotal())
		'MsgBox(GetTotal())
		'MsgBox(GetTotal())

		'Dim value(255) As Byte
		'Dim number As Integer

		'StringTest(value, number)
		'MsgBox(ToString(value))
		'MsgBox(number)

		''MsgBox(GetAge())
		'Dim result As Long = OpenLogTagFile("c:\test.ltd")
		'Dim tagInterface As New LOGTAG_INTERFACE()
		'OpenLogTagInterface("c:\test.ltd", tagInterface)
		'MsgBox(tagInterface.szManufactured)
	End Sub

	Function ToString(ByVal value As Byte()) As String
		'StrConv(value, vbUnicode)
		Dim encoding As System.Text.Encoding = New System.Text.UTF8Encoding()
		Return (encoding.GetString(value))
	End Function
End Module
